﻿//
//   Description:       Pixel shader that samples the color from an image and draws every odd pixel transparent.
//
//   Changed by:        $Author: Rene $
//   Changed on:        $Date: 2009-10-23 21:21:45 +0200 (Fr, 23 Okt 2009) $
//   Changed in:        $Revision: 49 $
//   Project:           $URL: file:///U:/Data/Development/SVN/SilverlightDemos/trunk/Shaders/ShaderSilverlightTestproject/ShaderSilverlightTestproject/Shader/TransparentAlternatingPixelsEffect.cs $
//   Id:                $Id: TransparentAlternatingPixelsEffect.cs 49 2009-10-23 19:21:45Z Rene $
//
//
//   Copyright (c) 2009 Rene Schulte
//
//   This program is open source software. Please read the License.txt.
//

using System;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Effects;
using System.Windows.Media.Media3D;


namespace Microsoft.Samples.ShaderEffects
{
   public class TransparentAlternatingPixelsEffect : ShaderEffect
   {
      #region Properties

      public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(TransparentAlternatingPixelsEffect), 0);
      public static readonly DependencyProperty TextureSizeProperty = DependencyProperty.Register("TextureSize", typeof(Point), typeof(TransparentAlternatingPixelsEffect), new PropertyMetadata(new Point(512, 512), PixelShaderConstantCallback(0)));

      public Brush Input
      {
         get
         {
            return ((Brush)(this.GetValue(InputProperty)));
         }
         set
         {
            this.SetValue(InputProperty, value);
         }
      }

      /// <summary>The Size of the texture.</summary>
      public Point TextureSize
      {
         get
         {
            return ((Point)(this.GetValue(TextureSizeProperty)));
         }
         set
         {
            this.SetValue(TextureSizeProperty, value);
         }
      }

      #endregion

      #region Contructors

      public TransparentAlternatingPixelsEffect()
      {
         PixelShader pixelShader = new PixelShader();
         //{
         //   UriSource = new Uri("/ShaderSilverlightTestproject;component/Shader/TransparentAlternatingPixels.ps", UriKind.Relative)
         //};
         pixelShader.UriSource = Global.MakePackUri("ShaderSource/TransparentAlternatingPixels.ps");
         
         this.PixelShader = pixelShader;

         this.UpdateShaderValue(InputProperty);
         this.UpdateShaderValue(TextureSizeProperty);
      }

      #endregion
   }
}
